#include <iostream>
#include <string>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "command.hpp"

using namespace std;

int main()
{
    // 打开信道
    int fd = open(FIFO_FILE, O_WRONLY);
    if (fd < 0)
    {
        perror("open");
        exit(FIFO_OPEN_ERR);
    }

    string line;
    // 开始通信
    while (true)
    {
        cout << "Please enter : ";
        cin >> line;
        
        write(fd, line.c_str(), line.size());
    }

    close(fd);
    return 0;
}